package com.admin.system.dao;

import com.admin.model.pojo.Dept;
import com.admin.model.pojo.Menu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (Dept)表数据库访问层
 *
 * @author makejava
 * @since 2021-01-31 20:16:25
 */
public interface DeptDao extends BaseMapper<Dept> {

    /**
     * 通过实体作为筛选条件查询
     *
     * @param dept 实例对象
     * @return 对象列表
     */
    List<Dept> queryAll(Dept dept);

    /**
     * 父部门id查询子部门
     * @param pid
     * @return
     */
    List<Dept> queryByPid(Long pid);

    /**
     * 用户id查询部门
     * @param userId
     * @return
     */
    @Select("SELECT * FROM sys_dept AS d LEFT JOIN sys_user_dept AS ud ON d.id = ud.dept_id WHERE ud.user_id = #{userId}")
    List<Dept> queryByUserId(Long userId);



}